<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/taglib_include.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, target-densitydpi=medium-dpi, initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<link href="${ctx}/css/main.css?ver=${main_css_version}" rel="stylesheet" type="text/css" />
<title>${projectTitle }</title>
</head>
<body>
  <header id="main-top">
    <a href="javascript:void(0);" id="back">
      <div id="main-top-left">
        <img src="${ctx}/images/mui_title_back_btn.png" class="img-2">
      </div>
    </a>
    <div id="main-top-title">车票数量</div>
    <a id="main-top-right" href="javascript:void(0);">
      <div>完成</div>
    </a>
  </header>
  <div id="container">
   <form action="${ctx}/order/passengernumlist.do" method="get" id="form">
    <div id="trains">
      <ul>
        <li>
          <div class="ticket">成人票</div>
          <input type="hidden" value="${adultnum}" id="adultnumhidden">
          <div class="Nticket" id="adult">
             <c:choose>
                  <c:when test="${isXiAnStation==true || isJIANYANGStation==true || isBYStation==true}">
                    <div>
                      <a href="#"><span>0</span></a>
                    </div>
                    <div>
                      <a href="#"><span>1</span></a>
                    </div>
                  </c:when>
                  <c:when test="${isZIYANGStation==true}">
                    <div>
                      <a href="#"><span>0</span></a>
                    </div>
                    <div>
                      <a href="#"><span>1</span></a>
                    </div>
                    <div>
                      <a href="#"><span>2</span></a>
                    </div>
                    <div>
                      <a href="#"><span>3</span></a>
                    </div>
                  </c:when>
                  <c:otherwise>
                    <div>
                      <a href="#"><span>0</span></a>
                    </div>
                    <div>
                      <a href="#"><span>1</span></a>
                    </div>
                    <div>
                      <a href="#"><span>2</span></a>
                    </div>
                    <div>
                      <a href="#"><span>3</span></a>
                    </div>
                    <div>
                      <a href="#"><span>4</span></a>
                    </div>
                    <div>
                      <a href="#"><span>5</span></a>
                    </div>
                  </c:otherwise>
             </c:choose>
          </div>
        </li>
     <c:if test="${isSellChildTicket}">
        <li>
          <div class="ticket">儿童票</div>
          <div class="Nticket" id="child">
            <div>
              <a href="#"><span>0</span></a>
            </div>
            <div>
              <a href="#"><span>1</span></a>
            </div>
            <div>
              <a href="#"><span>2</span></a>
            </div>
            <div>
              <a href="#"><span>3</span></a>
            </div>
            <div>
              <a href="#"><span>4</span></a>
            </div>
            <div>
              <a href="#"><span>5</span></a>
            </div>
          </div>
        </li>
      </c:if>  
      <c:if test="${isSellDisabledTicket}">
        <li>
          <div class="ticket">军残票</div>
          <div class="Nticket" id="special">
            <div>
              <a href="#"><span>0</span></a>
            </div>
            <div>
              <a href="#"><span>1</span></a>
            </div>
            <div>
              <a href="#"><span>2</span></a>
            </div>
            <div>
              <a href="#"><span>3</span></a>
            </div>
            <div>
              <a href="#"><span>4</span></a>
            </div>
            <div>
              <a href="#"><span>5</span></a>
            </div>
          </div>
        </li>
      </c:if>   
      <c:if test="${isSellFreeTicket}">
	         <li>
	          <div class="ticket">免 票</div>
	          <div class="Nticket" id="free">
                <c:choose>
                    <c:when test="${isXiAnStation==true || isJIANYANGStation==true || isBYStation==true}">
                        <div>
                          <a href="#"><span>0</span></a>
                        </div>
                        <div>
                          <a href="#"><span>1</span></a>
                        </div>
                    </c:when>
                    <c:when test="${isZIYANGStation==true}">
                        <div>
                          <a href="#"><span>0</span></a>
                        </div>
                        <div>
                          <a href="#"><span>1</span></a>
                        </div>
                        <div>
                          <a href="#"><span>2</span></a>
                        </div>
                        <div>
                          <a href="#"><span>3</span></a>
                        </div>
                    </c:when>
                    <c:otherwise>
                        <div>
                          <a href="#"><span>0</span></a>
                        </div>
                        <div>
                          <a href="#"><span>1</span></a>
                        </div>
                        <div>
                          <a href="#"><span>2</span></a>
                        </div>
                        <div>
                          <a href="#"><span>3</span></a>
                        </div>
                        <div>
                          <a href="#"><span>4</span></a>
                        </div>
                        <div>
                          <a href="#"><span>5</span></a>
                        </div>
                  </c:otherwise>
                </c:choose>
	          </div>
	        </li>
        </c:if>
      </ul>
           <!-- 隐藏表单 -->
		   <input type="hidden" name="startStationId" value="${orderconfirmbean.startStationId}"/>
		   <input type="hidden" name="arriveStationId" value="${orderconfirmbean.arriveStationId}"/>
		   <input type="hidden" name="leaveDate" value="${orderconfirmbean.leaveDate}"/>
		   <input type="hidden" name="leaveTime" value="${orderconfirmbean.leaveTime}"/>
		   <input type="hidden" name="regBusNoFoid" value="${orderconfirmbean.regBusNoFoid}"/>
		   <input type="hidden" name="regBusNo" value="${orderconfirmbean.regBusNo}"/>
		   <input type="hidden" name="price" value="${orderconfirmbean.price}"/>
		   <input type="hidden" name="halfPrice" value="${orderconfirmbean.halfPrice}"/>
		   <input type="hidden" name="fullStationCharge" value="${orderconfirmbean.fullStationCharge}"/>
		   <input type="hidden" name="halfStationCharge" value="${orderconfirmbean.halfStationCharge}"/>
		   <input type="hidden" name="schType" value="${orderconfirmbean.schType}"/>
		   <input type="hidden" name="busTypeName" value="${orderconfirmbean.busTypeName}"/>
		   <input type="hidden" name="startStationName" value="${orderconfirmbean.startStationName}"/>
		   <input type="hidden" name="arriveStationName" value="${orderconfirmbean.arriveStationName}"/>
		   <!--   <input type="hidden" name="passengtype" value="1"/>-->
		   <!-- 乘客类型和数量 -->
		   <input type="hidden" name="adultnum" id="adultnum" value="${orderconfirmbean.adultnum}"/>
           <input type="hidden" name="childnum" id="childnum" value="${orderconfirmbean.childnum}"/>
           <input type="hidden" name="specialnum" id="specialnum" value="${orderconfirmbean.specialnum}"/>
           <input type="hidden" name="freenum" id="freenum" value="${orderconfirmbean.freenum}"/>
           <input type="hidden" name="fullServicePrice" id="fullServicePrice" value="${orderconfirmbean.fullServicePrice}"/><!-- 全票服务费 -->
           <input type="hidden" name="ticketQueryURL" id="ticketQueryURL" value="${ticketQueryURL }"/>
           <input type="hidden" name="halfServicePrice" id="halfServicePrice" value="${orderconfirmbean.halfServicePrice}"/><!-- 半票服务费 -->
           <input type="hidden" name="surplusfreeNum" id="surplusfreeNum" value="${orderconfirmbean.surplusfreeNum}"/>
           <input type="hidden" name="hasPrivilege" id="hasPrivilege" value="${hasPrivilege}"/>
           <input type="hidden" name="fullInsurance" id="fullInsurance" value="${orderconfirmbean.fullInsurance}"/>
           <input type="hidden" name="halfInsurance" id="halfInsurance" value="${orderconfirmbean.halfInsurance}"/>
           <input type="hidden" name="hasNcStartStation" id="hasNcStartStation" value="${orderconfirmbean.hasNcStartStation}"/>  
           <input type="hidden" name="donatedInsurance" id="donatedInsurance" value="${orderconfirmbean.donatedInsurance}"/>
           <input type="hidden" name="isForceSaleInsurance" id="isForceSaleInsurance" value="${orderconfirmbean.isForceSaleInsurance }"/>
<%--            <input type="hidden" name="insuranceButtonEnabled" id="insuranceButtonEnabled" value="${orderconfirmbean.insuranceButtonEnabled}"/> --%>
    </div>
    </form>
    <div id="Nticket-tip">
		  <c:choose>
		     <c:when test="${isSellFreeTicket}">
                  <c:choose>
                     <c:when test="${isXiAnStation or isJIANYANGStation or isBYStation}">
                                                          温馨提示： <br><br>
                                                          单次购买成人票总数不能超过1张，免票数不能超过成人票数。<br>
                                                          免票: 一张成人票可携带一名身高在1.2米以下的儿童。
                     </c:when>
                     <c:when test="${isZIYANGStation}">
                                                          温馨提示： <br><br>
                                                          单次购买成人票总数不能超过3张，免票数不能超过成人票数。<br>
                                                          免票: 一张成人票可携带一名身高在1.2米以下的儿童。
                     </c:when>
                     <c:otherwise>
                                                              温馨提示： <br><br>
                                                              单次购买成人票总数不能超过五张，免票数不能超过成人票数。<br>
                                                              免票: 一张成人票可携带一名身高在1.2米以下的儿童。
                     </c:otherwise>
                  </c:choose>
		     </c:when>
		     <c:when test="${orderconfirmbean.startStationId == constant.lzxy_startstation_id}">
		                           温馨提示：<br><br>
		                           军警残半票: 持有效军警残证件可购买半票乘车时凭本人有效证件乘坐。<br>
		                           儿童半票: 身高在1.2-1.5米高的儿童享受儿童半票。<br>
		                           单次购买成人票和半票，总数不能超过五张。
		     </c:when>
		     <c:otherwise>
		                           温馨提示： <br><br>
                                               单次购买成人票，总数不能超过五张。
		     </c:otherwise>
		  </c:choose>
    </div>
  </div>
  <%@ include file="/WEB-INF/views/popup_alert.jsp"%>
  <script type="text/javascript" src="${ctx}/js/jquery.min.js?ver=${jquery_min_version}"></script>
  <!-- mergeTo:${ctx}/js/custom.min.js?ver=${custom_min_version} -->
  <script type="text/javascript" src="${ctx}/js/custom.js?ver=${custom_version}"></script>
  <!-- mergeTo -->
  <script type="text/javascript">
      var ss = $("div[id='adult']").find(".arr-number");
      var adultnum;
      var childnum = 0;
      var specialnum = 0;
      var freenum = 0;

       $(function(){
    	   var adultnumh = $("#adultnum").val();
    	   //成人票数量选择
    	   var adult = $("div[id='adult']").find("a");
    	   adult.each(function(){
    		   if(parseInt(adultnumh)==parseInt($(this).text())){
    			   $(this).find("span").each(function(){
                       $(this).attr("class","arr-number");
                   });
    		   }
    		   $(this).parent().parent().find(".arr-number").each(function(){
    			   adultnum = $(this).text();
    		   });
    		   //成人票选择人数绑定单击事件
    		   $(this).click(function(){
    			   adultnum = $(this).text();
    			   var aa = $(this).parent().parent().find(".arr-number").each(function(i){
    				   $(this).removeAttr("class");
    			   });			 
    			   $(this).find("span").each(function(){
    				   $(this).attr("class","arr-number");
    			   });
    		   });
    	   });
    	   //儿童票数量选择
    	   
    	    var childnumh = $("#childnum").val();
    	    var child = $("div[id='child']").find("a");
    	    child.each(function(){
    	    	if(childnumh!=0){
    	            if(parseInt(childnumh)==parseInt($(this).text())){
                        $(this).find("span").each(function(){
                            $(this).attr("class","arr-number");
                        });
                    }
    	    	} 	    	
    	        $(this).parent().parent().find(".arr-number").each(function(){
    	        	childnum = $(this).text();
                });
                //儿童票选择人数绑定单击事件
                $(this).click(function(){
                	childnum = $(this).text();
                    var c = $(this).parent().parent().find(".arr-number").each(function(i){
                        $(this).removeAttr("class");
                    });           
                    $(this).find("span").each(function(){
                        $(this).attr("class","arr-number");
                    });
                });
    	    });
    	   //军残票数量选择
    	    var specialnumh = $("#specialnum").val();
    	    var special = $("div[id='special']").find("a");
    	    special.each(function(){
    	    	if(specialnumh!=0){
    	    	     if(parseInt(specialnumh)==parseInt($(this).text())){
                         $(this).find("span").each(function(){
                             $(this).attr("class","arr-number");
                         });
                     }
    	    	}   	 
    	        $(this).parent().parent().find(".arr-number").each(function(){
    	        	specialnum = $(this).text();
                });
    	        //军残票选择人数绑定单击事件
    	        $(this).click(function(){
    	        	  specialnum = $(this).text();
                      var s = $(this).parent().parent().find(".arr-number").each(function(i){
                          $(this).removeAttr("class");
                      });           
                      $(this).find("span").each(function(){
                          $(this).attr("class","arr-number");
                      });
    	        });
    	        	
    	    });
    	   //免票数量选择
    	   var freenumh = $("#freenum").val();
    	   var free = $("div[id='free']").find("a");
    	   free.each(function(){
    		   if(freenumh != 0){
    	             if(parseInt(freenumh) == parseInt($(this).text())){
    	                   $(this).find("span").each(function(){
    	                       $(this).attr("class","arr-number");
    	                   });
    	               }
    		   }
    		   		   
    		   $(this).parent().parent().find(".arr-number").each(function(){
    			   freenum = $(this).text();
               });
               //免票选择人数绑定单击事件
               $(this).click(function(){
            	     freenum = $(this).text();
                     var s = $(this).parent().parent().find(".arr-number").each(function(i){
                         $(this).removeAttr("class");
                     });           
                     $(this).find("span").each(function(){
                         $(this).attr("class","arr-number");
                     });
               });
    	   });
    	   //点击完成绑定点击事件
    	   $("#main-top-right").bind("click",function(e){
               //判断成人票和半票总数不超过5张
               var totnum = parseInt(adultnum) + parseInt(childnum) + parseInt(specialnum);
               if(totnum > 5){
                   openAlert("票数超过5张");
                   return false;
               }
               if(totnum == 0){
                   openAlert("请至少购买一张车票");
                   return false;
               }
               //判断免票数是否超过成人票数
               if(parseInt(freenum) > parseInt(adultnum)){
                   openAlert("免票数量不能超过成人票数");
                   return false;
               }
               //给隐藏表单域赋值
               $("#adultnum").val(adultnum);
               $("#childnum").val(childnum);
               $("#specialnum").val(specialnum);
               $("#freenum").val(freenum);
               $("#form").submit();
    	   });
    	   
    	   //返回按钮绑定单击事件
    	   $("#back").bind("click",function(e){
               $("#form").submit();
           });
    		     	 
       });
  </script>
</body>
</html>